package com.example.anew.journey.mynewjourney.logic.splash.persenter;

import android.content.Context;

import com.example.anew.journey.mynewjourney.logic.splash.model.SplashModel;
import com.example.anew.journey.mynewjourney.logic.splash.view.ISplashView;

/**
 * 杭州惟君医疗科技有限公司10
 * Created by 20433 on 2018/3/6
 */

public class SplashPersenter {
    private ISplashView mIsplash;
    private SplashModel miSplashModel;

    public SplashPersenter(ISplashView mIsplash) {
        this.mIsplash = mIsplash;
        miSplashModel = new SplashModel();
    }

    /**
     * @desc 请求网络加载数据的逻辑
     */
    public void requestNetwork(final Context mcontext) {
        new Thread(new Runnable() {
            @Override
            public void run() {
                boolean islogin = false;
                try {
                    islogin = miSplashModel.takeData(mcontext);
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                } finally {
                    if (islogin) {
                        mIsplash.toMainPager();
                    }else{
                        mIsplash.toRegisteredOrLoginActivity();
                    }

                    //mIsplash.toRegisteredOrLoginActivity();
                }
            }
        }).start();
    }

    /**
     * @desc 执行动画
     */
    public void PerformAnimation() {
        mIsplash.PerformAnimation();
    }
}
